using MediatR;
using SumerCoreDevOps.Application.Users.Queries;
using SumerCoreDevOps.Domain.Entities;
using SumerCoreDevOps.Infrastructure.Identity;

namespace SumerCoreDevOps.Application.Users.Handlers;

/// <summary>
/// 获取所有用户查询处理器
/// </summary>
public class GetAllUsersQueryHandler : IRequestHandler<GetAllUsersQuery, List<User>>
{
    private readonly UserManager _userManager;

    public GetAllUsersQueryHandler(UserManager userManager)
    {
        _userManager = userManager;
    }

    public async Task<List<User>> Handle(GetAllUsersQuery request, CancellationToken cancellationToken)
    {
        return await _userManager.GetAllUsersAsync();
    }
}
